package com.atguigu.gmall.user.service;

import com.atguigu.gmall.common.util.MD5;
import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.user.mapper.UserInfoMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: lx
 * @Time: 15:56
 * @Description:
 */
@Service
public class LoginServiceImpl implements LoginService {


    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo login(UserInfo userInfo) {
       return userInfoMapper.selectOne(new QueryWrapper<UserInfo>().
                eq("login_name", userInfo.getLoginName())
                 .eq("passwd",MD5.encrypt(userInfo.getPasswd())));

    }

    public static void main(String[] args) {
        String password = "123";
        //String salt = "regnghjyerttyu";
        //password = password + salt;
        String encrypt = MD5.encrypt(password);
        System.out.println(encrypt);
    }
}
